#!/usr/bin/ruby

out = `ls -r --sort=time /local/joofeit/TF`
puts out.split("\n")
counter =0

if (out.split("\n").length >3)
  while counter <out.split("\n").length-2
   copy = "scp /local/joofeit/TF/"+out.split("\n")[counter]+" joofeit@chattr:/media/HOPPYLABEL/cluster-16/TF"
    #c="scp /local/joofeit/outSearcher1204 joofeit@chattr:/media/HOPPYLABEL"
    system copy
    remove ="rm -f /local/joofeit/TF/"+out.split("\n")[counter]
    system remove
    #puts out.split("\n")[counter]
    counter=counter+1
  end
end
